static void
gdk_drop_default_status (GdkDrop *self,
- GdkDragAction actions)
+ GdkDragAction actions,
+ GdkDragAction preferred)
{
}
* @self: a #GdkDrop
* @actions: Supported actions of the destination, or 0 to indicate
* that a drop will not be accepted
+ * @preferred: A unique action that's a member of @actions indicating the
+ * preferred action.
*
* Selects all actions that are potentially supported by the destination.
*
* the ones provided by gdk_drop_get_actions(). Those actions may
* change in the future, even depending on the actions you provide here.
*
+ * The @preferred action is a hint to the drag'n'drop mechanism about which
+ * action to use when multiple actions are possible.
+ *
* This function should be called by drag destinations in response to
* %GDK_DRAG_ENTER or %GDK_DRAG_MOTION events. If the destination does
* not yet know the exact actions it supports, it should set any possible
*/
void
gdk_drop_status (GdkDrop *self,
- GdkDragAction actions)
+ GdkDragAction actions,
+ GdkDragAction preferred)
{
#ifndef G_DISABLE_CHECKS
GdkDropPrivate *priv = gdk_drop_get_instance_private (self);
g_return_if_fail (GDK_IS_DROP (self));
g_return_if_fail (priv->state != GDK_DROP_STATE_FINISHED);
+ g_return_if_fail (gdk_drag_action_is_unique (preferred));
+ g_return_if_fail ((preferred & actions) == preferred);
- GDK_DROP_GET_CLASS (self)->status (self, actions);
+ GDK_DROP_GET_CLASS (self)->status (self, actions, preferred);
}
/**
GDK_AVAILABLE_IN_ALL
void gdk_drop_status (GdkDrop *self,
- GdkDragAction actions);
+ GdkDragAction actions,
+ GdkDragAction preferred);
GDK_AVAILABLE_IN_ALL
void gdk_drop_finish (GdkDrop *self,
GdkDragAction action);
GObjectClass parent_class;
void (* status) (GdkDrop *self,
- GdkDragAction actions);
+ GdkDragAction actions,
+ GdkDragAction preferred);
void (* finish) (GdkDrop *self,
GdkDragAction action);
static void
gdk_wayland_drop_commit_status (GdkWaylandDrop *wayland_drop,
- GdkDragAction actions)
+ GdkDragAction actions,
+ GdkDragAction preferred)
{
GdkDisplay *display;
uint32_t preferred_action;
dnd_actions = gdk_to_wl_actions (actions);
-
- if (dnd_actions & WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY)
- preferred_action = WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY;
- else if (dnd_actions & WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE)
- preferred_action = WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE;
- else if (dnd_actions & WL_DATA_DEVICE_MANAGER_DND_ACTION_ASK)
- preferred_action = WL_DATA_DEVICE_MANAGER_DND_ACTION_ASK;
- else
- preferred_action = 0;
+ preferred_action = gdk_to_wl_actions (preferred);
wl_data_offer_set_actions (wayland_drop->offer, dnd_actions, preferred_action);
}
static void
gdk_wayland_drop_status (GdkDrop *drop,
- GdkDragAction actions)
+ GdkDragAction actions,
+ GdkDragAction preferred)
{
GdkWaylandDrop *wayland_drop = GDK_WAYLAND_DROP (drop);
- gdk_wayland_drop_commit_status (wayland_drop, actions);
+ gdk_wayland_drop_commit_status (wayland_drop, actions, preferred);
}
static void
if (action)
{
- gdk_wayland_drop_commit_status (wayland_drop, action);
+ gdk_wayland_drop_commit_status (wayland_drop, action, action);
if (display_wayland->data_device_manager_version >=
WL_DATA_OFFER_FINISH_SINCE_VERSION)
static void
gdk_win32_drop_status (GdkDrop *drop,
- GdkDragAction actions)
+ GdkDragAction actions,
+ GdkDragAction preferred)
{
GdkWin32Drop *drop_win32 = GDK_WIN32_DROP (drop);
GdkDrag *drag;
g_return_if_fail (drop != NULL);
GDK_NOTE (DND, g_print ("gdk_win32_drop_status: %s\n"
- " context=%p:{source_actions=%s}\n",
+ " context=%p:{source_actions=%s, preferred=%s}\n",
_gdk_win32_drag_action_to_string (actions),
drop,
- _gdk_win32_drag_action_to_string (gdk_drop_get_actions (drop))));
+ _gdk_win32_drag_action_to_string (gdk_drop_get_actions (drop)),
+ _gdk_win32_drag_action_to_string (preferred)));
drop_win32->actions = actions;
static void
gdk_x11_drop_status (GdkDrop *drop,
- GdkDragAction actions)
+ GdkDragAction actions,
+ GdkDragAction preferred)
{
GdkX11Drop *drop_x11 = GDK_X11_DROP (drop);
GdkDragAction possible_actions, suggested_action;
if (drop_x11->suggested_action != 0)
suggested_action = drop_x11->suggested_action;
- else if (possible_actions & GDK_ACTION_COPY)
- suggested_action = GDK_ACTION_COPY;
- else if (possible_actions & GDK_ACTION_MOVE)
- suggested_action = GDK_ACTION_MOVE;
- else if (possible_actions & GDK_ACTION_ASK)
- suggested_action = GDK_ACTION_ASK;
else
- suggested_action = 0;
+ suggested_action = preferred & possible_actions;
+
+ if (suggested_action == 0 && possible_actions != 0)
+ {
+ if (possible_actions & GDK_ACTION_COPY)
+ suggested_action = GDK_ACTION_COPY;
+ else if (possible_actions & GDK_ACTION_MOVE)
+ suggested_action = GDK_ACTION_MOVE;
+ else if (possible_actions & GDK_ACTION_ASK)
+ suggested_action = GDK_ACTION_ASK;
+ else
+ suggested_action = 0;
+ }
xev.xclient.type = ClientMessage;
xev.xclient.message_type = gdk_x11_get_xatom_by_name_for_display (display, "XdndStatus");
if (self->waiting)
{
- gdk_drop_status (drop, 0);
+ gdk_drop_status (drop, 0, 0);
self->waiting = FALSE;
}
self->active = FALSE;
if (!self->waiting)
return FALSE;
- gdk_drop_status (drop, actions);
+ gdk_drop_status (drop, actions, preferred_action);
self->waiting = FALSE;
return TRUE;
}